clear all
set more off
set matsize 10000
tempfile ubigeo temp


local lista trust_police trust_army trust_church trust_newsp trust_rtv trust_parties trust_regi trust_jury trust_parliament trust_jne trust_onpe
local controls schooling male rural native married head 

use mergedp8090, clear

egen voted_bn = rowmax(voted_blank voted_null)
recode voted_blank voted_null voted_bn (. = 0) if voted == 0

** LABELS
label var todoAT80 "Violence Exposure - 80s"
label var todoAT90 "Violence Exposure - 90s"

******* Results
drop if vote_matter == .
local lista vote_matter voted voted_blank voted_null voted_bn partN dem_works dem_matters1 gov_demo1 gov_auto1

local r = 1
foreach var in `lista' {
	replace `var' = `var' * 100 if `r' != 6
	reghdfe `var' todoAT80 todoAT90 `controls', abs(ubigeo1993 ubigeonac1993 i.ubigeo1993#i.ubigeonac1993 i.age i.year i.provid#c.trend) vce(cluster ubigeonac1993) keepsin
	est store reg`r'
	sum `var' if e(sample) == 1
	local y = r(mean)
	sum todoAT80 if e(sample) == 1 & todoAT80
	local sd80 = r(mean)
	sum todoAT90 if e(sample) == 1 & todoAT90
	local sd90 = r(mean)
	local n80`r' = (round(((_b[todoAT80]) * `sd80') / `y', 0.0001)) * 100
	local n90`r' = (round(((_b[todoAT90]) * `sd90') / `y', 0.0001)) * 100
	local ++r
}

noisily estout reg* ///
using Table_B5_0.tex, style(tex) c(b(fmt(2) star) se(par fmt(2))) ///
	label collabels(, none) eqlabels(none) mlabels(, none) varlabel(_cons " $ Control $ ") starlevel(* .1 ** .05 *** .01) ///
	keep(todoAT80 todoAT90) ///
	order(todoAT80 todoAT90) ///
	stats(r2 N N_clust, fmt(%9.2f %9.0g) labels(`"$ R ^{2}$"' "Observations" "Clusters")) replace 

texdoc init Table_B5.tex, replace
tex \begin{table}[h]
tex \caption{Impact of armed conflict on voting, participation and democratic beliefs: 80s and 90s}
tex \label{tab:table1}
tex \begin{center}
tex \resizebox{16cm}{!}{
tex \begin{tabular}{lcccccccccc} \hline \hline
tex \\
tex & Voting & \multicolumn{4}{c}{Voted in last elections}& Participation & \multicolumn{2}{c}{Democracy} & \multicolumn{2}{c}{Type of preferred gov.} \\
tex & matters & Yes & ...blank & ...null & ... blank or null & organisations & works & matters & Democracy & Autocracy \\
tex \hline
tex \input{Table_B5_0.tex}
tex &&&&&&&&&& \\
tex \multicolumn{8}{l}{\textbf{Effect of 1 s.d. change in conflict measure as \% of mean of dependent variable:}} \\
tex & `n801' & `n802' & `n803' & `n804' & `n805' & `n806' & `n807' & `n808' & `n809' & `n8010' \\
tex & `n901' & `n902' & `n903' & `n904' & `n905' & `n906' & `n907' & `n908' & `n909' & `n9010' \\
tex &&&&&&&&&& \\
tex \hline
tex \end{tabular}}
tex \end{center}
tex \end{table}
